package com.cloudcc.mobile.weight.ui;

import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;

public class CircleImageDrawable extends Drawable {
	private Paint mPaint;
	private int mWidth;
	private int backgroudColor;
	private int foreground;

	public CircleImageDrawable(int backgroudColor, int foreground) {
		super();
		this.backgroudColor = backgroudColor;
		this.foreground = foreground;

		mPaint = new Paint();
		mPaint.setAntiAlias(true);
		mPaint.setColor(foreground);
		mPaint.setStyle(Style.FILL);
	}

	@Override
	public void draw(Canvas canvas) {
		mWidth = Math.min(canvas.getWidth(), canvas.getHeight());
		canvas.drawColor(backgroudColor);
		canvas.drawCircle(mWidth / 2, mWidth / 2, mWidth / 4, mPaint);
	}

	@Override
	public void setAlpha(int alpha) {
		mPaint.setAlpha(alpha);
	}

	@Override
	public void setColorFilter(ColorFilter cf) {
		mPaint.setColorFilter(cf);
	}

	@Override
	public int getOpacity() {
		return PixelFormat.TRANSLUCENT;
	}

}
